package concole;

import java.io.Serializable;
import java.net.MulticastSocket;

import remoteService.ClientHelper;
import remoteService.MultiClientHelper;

public class User implements Serializable {
	protected String ID;
	protected String password;
	protected int userNumber;
	protected Identification identity;
	ClientHelper cHelper;
	MultiClientHelper multiClientHelper;

	public User() {
		cHelper = new ClientHelper();
		//multiClientHelper = new MultiClientHelper();
	}

	public User(String ID, String password, boolean isLoginOrRegister) {
		this.ID = ID;
		this.password = password;
		cHelper = new ClientHelper();
		if (isLoginOrRegister) {
			cHelper = new ClientHelper();
		}
	}

	public User(Identification i) {
		this.identity = i;
	}

	public User(int number) {
		this.userNumber = number;
	}

	public Identification getIdentity() {
		return this.identity;
	}

	public void setIdentity(Identification identity) {
		this.identity = identity;
	}

	public String getNum() {
		return this.ID;
	}

	public String getPassword() {
		return this.password;
	}

	public void startOperation() {

	}

	public String toCheckString() {
		return this.identity + " " + this.ID + " " + this.password;
	}

	public String processRemoteLogin(User user, String filename) {
		String reply = "";
		String fileNameString = filename;
		// cHelper=new ClientHelper();
		int identityInt = 0;
		if (user.identity == Identification.TEACHER) {
			identityInt = 1;
		} else if (user.identity == Identification.STUDENT) {
			identityInt = 2;
		}
		String standardLoginCmd = "Login!" + identityInt + "!" + user.getNum()
				+ "!" + filename;
		// get the stored password from the server

		 reply=cHelper.sendToNet(standardLoginCmd);
		//reply = multiClientHelper.sendToNet(standardLoginCmd);
		return reply;
	}
}
